package com.project.institute.DAO;

import com.project.common.screens.Login;
import com.project.trac.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.Gravity;
import android.widget.TextView;

public class InstituteList extends ListActivity  implements InstituteInterface {

	private Institute inst = new Institute();
	
	public int getRole() {
		return inst.getRole();
	}
	
	public int getUserID() {
		return inst.getUserID();
	}
	
	public int getSubjectID() {
		return inst.getSubjectID();
	}
	
	public int getScheduleID() {
		return inst.getScheduleID();
	}
	
	public String getUsername() {
		return inst.getUsername();
	}
	
	public String getFirstName() {
		return inst.getFirstName();
	}
	
	public String getSubjectName() {
		return inst.getSubjectName();
	}
	
	@Override
	public void Logout(final Activity activity) {
		
		TextView textView = new TextView(activity);
		textView.setText("You will be logged out of the system!");
		textView.setTextAppearance(activity.getApplicationContext(), R.style.alert_message);
		textView.setGravity(Gravity.CENTER_HORIZONTAL);

		new AlertDialog.Builder(activity)
				.setTitle("Alert").setView(textView)
				.setIcon(android.R.drawable.ic_dialog_info)
				.setCancelable(false)
				.setPositiveButton(android.R.string.yes,
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {
								getApplication().startActivity(new Intent(activity, Login.class)
								.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
								activity.finish();
							}
						})
				.setNegativeButton(android.R.string.no,
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {
								dialog.cancel();
							}
						}).create().show();
	}

	public void setSubjectID(int subjectId) {
		inst.setSubjectID(subjectId);
	}

	public void setScheduleID(int scheduleId) {
		inst.setScheduleID(scheduleId);
	}
	
	public void setSubjectName(String subjectName) {
		inst.setSubjectName(subjectName);
	}
	
}
